//
//  BIZTagListCollectionViewCell.m
//  biz
//
//  Created by zhangfuwei on 2017/3/22.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "BIZTagListCollectionViewCell.h"
#import "BIZMoviePlayCategoryListDataModel.h"

@interface BIZTagListCollectionViewCell ()

//@property (strong, nonatomic) IBOutlet UIButton *tagButton;
/** tagButton */
@property (nonatomic, strong) UIButton *tagButton;


@end

@implementation BIZTagListCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self.contentView addSubview:self.tagButton];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.tagButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}

- (void)setListDataM:(BIZMoviePlayCategoryListDataModel *)listDataM {
    _listDataM = listDataM;
    [self.tagButton setTitle:listDataM.name forState:UIControlStateNormal];
    [self layoutIfNeeded];
    
}

-(void)setTextStr:(NSString *)textStr {
    
    _textStr = textStr;
    [self.tagButton setTitle:textStr forState:UIControlStateNormal];
    [self layoutIfNeeded];

}

- (void)tagBtnClick:(UIButton *)sender {
    !_clickBlock ?:_clickBlock();
}

#pragma mark -- lazyload

-(UIButton *)tagButton {
    if (!_tagButton) {
        
        _tagButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _tagButton.layer.cornerRadius = 5;
        _tagButton.clipsToBounds = YES;
        
        [_tagButton setTitleColor:COLOR_WORD_GRAY_1 forState:UIControlStateNormal];
        [_tagButton setTitleColor:COLOR_WORD_RED forState:UIControlStateSelected];
        
        [_tagButton setBackgroundImage:[UIImage imageNamed:@"tagcell_bg_normal"] forState:UIControlStateNormal];
        
        [_tagButton setBackgroundImage:[UIImage imageNamed:@"tagcell_bg_selected"] forState:UIControlStateSelected];
        
        _tagButton.titleLabel.font = CHINESE_SYSTEM(14);
        _tagButton.userInteractionEnabled = NO;
        [_tagButton addTarget:self action:@selector(tagBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _tagButton;
}

@end
